<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var objs = document.getElementsByName("userId");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != 0 && objs[i].checked)sign = sign + 1;
		}
		if(sign <= 0){
			alert("<fmt:message key='myRecycle.message.select'/>");
			return false;
		}
		return true;
	}

	function back(){
		var sign = "<c:out value='${sign}'/>";
		var customerId = "<c:out value='${customerId}'/>";
		window.location.href = "./customerManage.do?action=shareCustomer&customerId="+customerId+"&sign="+sign;
		window.location.target = "main";
	}
	
	function save(){
		var sign = "<c:out value='${sign}'/>";
		var curValue = document.all.isReadWrite.value;
		if(checkForm()){
			if(curValue != '-1'){
				document.updateShareCustomerForm.action = "./customerManage.do?action=updateShareCustomer&sign="+sign;
				document.updateShareCustomerForm.target = "main";
				document.updateShareCustomerForm.submit();
			}else{
				alert("<fmt:message key='customer.message.sharePri'/>");
			}
		}
	}
	
-->
</script>
</head>
<body>
<form name="updateShareCustomerForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" colspan="3">
							共享客户
						</td>
					</tr>
					<tr>
						<td valign="bottom" class="a_tools" style="padding-left: 3px;">
							请选择共享权限<fmt:message key='common.sign'/>
							<select id="isReadWrite" name="isReadWrite">
								<option value="-1">----------<fmt:message key='common.select.option'/>----------</option>
								<option value="0"><fmt:message key='customer.select.read'/></option>
								<option value="1"><fmt:message key='customer.select.write'/></option>
							</select>
							|
							<a class="add" href="javascript:save();" hidefocus="true">确定</a>
						</td>
						<td></td>
						<td align="right" valign="bottom">
							<a href="javascript:back();" hidefocus="true">返回列表</a>&nbsp;&nbsp;
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">
							请选择共享用户
						</td>
					</tr>
					<tr>
						<td>
							<table class="table">
								<tr>
									<td valign="top">
										<div style="width:100%;height:420px;overflow-x: hidden;overflow-y: scroll;">
										<table class="table_style">
											<tr>
												<td class="title" width="8"></td>
												<td class="title" width="30"><fmt:message key='common.lable.checkbox'/></td>
												<td class="title"><fmt:message key='customer.lable.empName'/></td>
												<td class="title"><fmt:message key='customer.lable.byDept'/></td>
											</tr>
											<c:forEach var="user" items="${users}">
											<c:if test="${user.id != userId}">
											<tr onmouseover="onmousemoveChange(this,'img${user.id}')" onmouseout="onmouseoutChange(this,'img${user.id}')">
												<td height="16" width="8" align="right"><img id="img${user.id}" src="./images/table_sign2.bmp"></td>
												<td><input id="userId" name="userId" type="checkbox" value="${user.id}"/></td>
												<td>${user.userName}</td>
												<td>${user.deptName}</td>
											</tr>
											</c:if>
											</c:forEach>
										</table>
										</div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<input id="customerId" name="customerId" value="${customerId}" type="hidden"/>
</form>
</body> 
</html>